{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "complimentary-gregory",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/toeplitz-matrix\n",
    "\n",
    "\n",
    "Runtime: 12 ms, faster than 61.19% of Go online submissions for Toeplitz Matrix.\n",
    "Memory Usage: 4.5 MB, less than 100.00% of Go online submissions for Toeplitz Matrix.\n",
    "\n",
    "\n",
    "```go\n",
    "package main\n",
    "\n",
    "import (\n",
    "\t\"fmt\"\n",
    ")\n",
    "\n",
    "type MyMatrix struct {\n",
    "\tmatrix [][]int\n",
    "\theight int\n",
    "\twidth  int\n",
    "}\n",
    "\n",
    "func (this MyMatrix) is_in_matrix(x int, y int) bool {\n",
    "\tif x < this.width && y < this.height {\n",
    "\t\treturn true\n",
    "\t} else {\n",
    "\t\treturn false\n",
    "\t}\n",
    "}\n",
    "\n",
    "func (this MyMatrix) is_it_ok(start_x int, start_y int) bool {\n",
    "\tif !(this.is_in_matrix(start_x, start_y)) {\n",
    "\t\treturn false\n",
    "\t} else {\n",
    "\t\tvalue := this.matrix[start_y][start_x]\n",
    "\t\tfor this.is_in_matrix(start_x+1, start_y+1) {\n",
    "\t\t\tstart_x += 1\n",
    "\t\t\tstart_y += 1\n",
    "\t\t\tif this.matrix[start_y][start_x] != value {\n",
    "\t\t\t\treturn false\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t\treturn true\n",
    "\t}\n",
    "}\n",
    "\n",
    "func isToeplitzMatrix(matrix [][]int) bool {\n",
    "\t//8:38\n",
    "\tmyMatrix := MyMatrix{matrix, len(matrix), len(matrix[0])}\n",
    "\tfor y := 0; y < myMatrix.height; y++ {\n",
    "\t\tif myMatrix.is_it_ok(0, y) == false {\n",
    "\t\t\treturn false\n",
    "\t\t}\n",
    "\t}\n",
    "\tfor x := 0; x < myMatrix.width; x++ {\n",
    "\t\tif myMatrix.is_it_ok(x, 0) == false {\n",
    "\t\t\treturn false\n",
    "\t\t}\n",
    "\t}\n",
    "\treturn true\n",
    "\t//9:05\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "confirmed-manchester",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.15.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
